{% extends "blog/base.html" %}

{% block css %}
<link type="text/css" rel="stylesheet" href="/static/blog/css/SyntaxHighlighter/shCoreDefault.css"><link> 
{% endblock %}

{% block js %}
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> 
<script language="JavaScript" src="/static/blog/js/SyntaxHighlighter/shCore.js"></script> 
<script language="JavaScript" src="/static/blog/js/SyntaxHighlighter/shAutoloader.js"></script>
<!--
<script language="JavaScript" src="/static/blog/js/SyntaxHighlighter/shBrushCSharp.js"></script>
<script language="JavaScript" src="/static/blog/js/SyntaxHighlighter/shBrushCss.js"></script>
<script language="JavaScript" src="/static/blog/js/SyntaxHighlighter/shBrushJava.js"></script>
<script language="JavaScript" src="/static/blog/js/SyntaxHighlighter/shBrushJScript.js"></script>
<script language="JavaScript" src="/static/blog/js/SyntaxHighlighter/shBrushPlain.js"></script>
<script language="JavaScript" src="/static/blog/js/SyntaxHighlighter/shBrushPython.js"></script>
<script language="JavaScript" src="/static/blog/js/SyntaxHighlighter/shBrushSql.js"></script>
<script language="JavaScript" src="/static/blog/js/SyntaxHighlighter/shBrushXml.js"></script>
-->
<script language="JavaScript" src="/static/blog/js/jquery.pagination.js"></script> 
<script language="JavaScript"> 
    $(document).ready(function(){
		SyntaxHighlighter.autoloader(
		  'cpp c                  /static/blog/js/SyntaxHighlighter/shBrushCpp.js',
		  'c# c-sharp csharp      /static/blog/js/SyntaxHighlighter/shBrushCSharp.js',
		  'css                    /static/blog/js/SyntaxHighlighter/shBrushCss.js',
		  'java                   /static/blog/js/SyntaxHighlighter/shBrushJava.js',
		  'js jscript javascript  /static/blog/js/SyntaxHighlighter/shBrushJScript.js',
		  'text plain             /static/blog/js/SyntaxHighlighter/shBrushPlain.js',
		  'py python              /static/blog/js/SyntaxHighlighter/shBrushPython.js',
		  'sql                    /static/blog/js/SyntaxHighlighter/shBrushSql.js',
		  'xml xhtml xslt html    /static/blog/js/SyntaxHighlighter/shBrushXml.js',
		  'go                     /static/blog/js/SyntaxHighlighter/shBrushGo.js'
		);
		SyntaxHighlighter.all();
	});
	//SyntaxHighlighter.all();

	var enable_load = false;
	$(function(){
		$('body').ajaxStart(function(){
			$(this).addClass('overlay')
		});
		$('body').ajaxComplete(function(){
			$(this).removeClass('overlay')
		});
		
		$("div#footer-bottom p.bottom-right a:last").click(function(){
			targetOffset = $("body").offset().top;
			$('html,body').stop().animate({scrollTop: targetOffset}, 500);
			return false;
		});
		
		$("#Pagination").pagination("{{ n_articles }}",{
			callback:pageselectCallback,
			prev_text: '&laquo 上一页',
			next_text: '下一页 &raquo;',
			items_per_page: 10,
			num_display_entries:6,
			current_page: '{{ page }}',
			num_edge_entries: 2,
			link_to: '#main',
			prev_show_always:false,
			next_show_always:false
		});
	})
	
	function pageselectCallback(page_id, jq) { 
	    if(enable_load){
	        location.href = "http://qinxuye.me/page/" + (Number(page_id)+1);
		}
		else{
			enable_load = true;
		}
		//initData(page_id); 
	} 
	
	/*function initData(pageIndex){
		if(enable_load){
			$.ajax({
				type: "GET",
			    url: "/page/" + (Number(pageIndex)+1) + "?from=ajax",
			    success: function(msg){
					$("#main div.post").remove();
			        $(msg).prependTo("#main");
					SyntaxHighlighter.highlight();
			    }
			});
		}
		else{
			enable_load = true;
		}
	}*/
	
</script> 
{% endblock %}

{% block content %}
    {% if article_list %}
        {% for article in article_list %}
		<div class="post">

      		<div class="right">

            	<h2><a href="{{ article.get_absolute_url }}">{{ article.title }}</a>&nbsp;<g:plusone href="http://qinxuye.me{{ article.get_absolute_url }}"></g:plusone></h2>

               <p class="post-info">文章在分类 <a href="{{ article.category.get_absolute_url }}">{{ article.category }}</a>下</p>

               {{ article.content_abstract|safe }}

               <p><a class="more" href="{{ article.get_absolute_url }}">继续阅读整篇文章 &raquo;</a></p>

            </div>

            <div class="left">

            	<p class="dateinfo">{{ article.modified|date:"M" }}<span>{{ article.modified|date:"j" }}</span></p>

               	<div class="post-meta">
                  	<h4>文章信息</h4>
                     	<ul>
                           <li class="user"><a href="#">{{ article.author }}</a></li>
                           <li class="time"><a href="#">{{ article.modified|date:"P" }}</a></li>
                           <li class="comment"><a href="{% if article.n_comment > 0 %}{{ article.get_absolute_url }}#comment{% else %}#{% endif %}">{{ article.n_comment }}个评论</a></li>
                           <li class="permalink"><a href="{{ article.get_absolute_url }}">持久链接</a></li>
                        </ul>
						</div>

            </div>

			</div>

		{% endfor %}
		{% if n_articles > 10 %}
		    <div id="Pagination" class="pagination"></div>
		{% endif %}
    {% endif %}
{% endblock %}

{% block cate %}
    {% if cate_list %}
	    {% for cate in cate_list %}
		<li><a href="{{ cate.get_absolute_url }}">{{ cate.name }}</a></li>
		{% endfor %}
	{% endif %}
{% endblock %}

{% block cate2 %}
	{% if cate_list %}
	    {% for cate in cate_list %}
		<li><a href="{{ cate.get_absolute_url }}">{{ cate.name }}</a></li>
		{% endfor %}
	{% endif %}
{% endblock %}

{% block popular %}
    {% if popular_article_list %}
	    <div class="popular">
	    	<h3>点击排行</h3>
			<ul>				
	        {% for pop in popular_article_list %}
				<li><a href="{{ pop.get_absolute_url }}">{{ pop.title }}</a>
					<br /><span>发表于{{ pop.created|date:"Y bj日 P" }}</span>
				</li>
		    {% endfor %}
		    </ul>
		</div>
	{% endif %}
{% endblock %}

{% block tagclouds %}
   {% if tag_list %}			
	  {% for tag in tag_list %}
		<li><a href="{{ tag.get_absolute_url }}" style="font-size: {{tag.font_size}}px;">{{ tag.name }}</a>
		</li>
     {% endfor %}
   {% endif %}
{% endblock %}

{% block friend %}
	{% if friends %}
		{% for friend in friends %}
			<li><a href="{{ friend.site }}"{% if friend.weibo_name %} wb_screen_name="{{ friend.weibo_name }}"{% endif %}>{{ friend.username }}</a></li>
		{% endfor %}
	{% else %}
	<li><a href="#">暂无好友</a></li>
	{% endif %}
{% endblock %}

{% block comment %}
	{% if comment_list %}
		{% for comment in comment_list %}
		<li><a href="{{ comment.article.get_absolute_url }}#comment-{{ comment.id }}" title="{{ comment.content }}">{{ comment.content|safe }}</a><br /> &#45; <cite>{{ comment.username }}</cite></li>
		{% endfor %}
	{% else %}
	<li><a href="#">暂无评论</a></li>
	{% endif %}
{% endblock %}

{% block footerjs %}
<script type="text/javascript">
  window.___gcfg = {lang: 'zh-CN'};

  (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();
</script>
{% endblock %}